package api

import (
	v1 "cn.bupt.byy/monitor/api/v1"
	"cn.bupt.byy/monitor/docs"
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"

	swaggerFiles "github.com/swaggo/files"
	ginSwagger "github.com/swaggo/gin-swagger"
)

// InitRouter initialize routing information
func InitRouter() *gin.Engine {
	r := gin.Default()
	r.Use(cors.Default())

	docs.SwaggerInfo.BasePath = "/api/v1"

	apiV1 := r.Group("/api/v1")
	{
		//获取标签列表
		apiV1.GET("/listNodes", v1.ListNodes)
		apiV1.GET("/listAll", v1.ListAll)

		apiV1.GET("/operation", v1.CreateApp)
		apiV1.POST("/operation", v1.CreateAppOnAssignmentNode)
		apiV1.DELETE("/operation", v1.DeleteApp)
		apiV1.PUT("/operation", v1.PutAppOnAssignmentNode)
	}

	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
	return r
}
